 package gov.sat.tax.fwsk.wlrz;
 
 import java.io.PrintStream;
 import java.util.StringTokenizer;
 
 public class TransRzParaBean
 {
   private String Cryptext = "";
   private byte[] byteData;
   private String strRZData = null;
   private int[] nsrsbh_offset;
   private int[] gfsbh_offset;
   private int[] xfsbh_offset;
   private int[] fp_dm_offset;
   private int[] fp_hm_offset;
   private int[] kprq_offset;
   private int[] kpyear_offset;
   private int[] kpmonth_offset;
   private int[] kpday_offset;
   private int[] je_offset;
   private int[] se_offset;
   private int[] mw1_offset;
   private int[] mw2_offset;
   private int[] mw3_offset;
   private int[] mw4_offset;
   private int[] sym_offset;
   private int[] jmbb_offset;
   private int[] gd_offset;
   public boolean newVer = false;
   
   public byte[] doDecrypt(String Cryptograph)
   {
     CryptographerBean Rdec = new CryptographerBean();
     this.byteData = Rdec.RealTmDecrypt(Cryptograph);
     this.strRZData = new String(this.byteData);
     
 
     return this.byteData;
   }
   
   public TransRzParaBean(int log)
   {
     this.nsrsbh_offset = new int[] { 0, 20 };
     this.gfsbh_offset = new int[] { 20, 40 };
     this.xfsbh_offset = new int[] { 40, 60 };
     this.fp_dm_offset = new int[] { 60, 70 };
     this.fp_hm_offset = new int[] { 70, 78 };
     this.kprq_offset = new int[] { 78, 86 };
     this.kpyear_offset = new int[] { 78, 82 };
     this.kpmonth_offset = new int[] { 82, 84 };
     this.kpday_offset = new int[] { 84, 86 };
     this.je_offset = new int[] { 86, 105 };
     this.se_offset = new int[] { 105, 124 };
     this.mw1_offset = new int[] { 124, 151 };
     this.mw2_offset = new int[] { 151, 178 };
     this.mw3_offset = new int[] { 178, 205 };
     this.mw4_offset = new int[] { 205, 232 };
     this.sym_offset = new int[] { 232, 248 };
     this.jmbb_offset = new int[] { 248, 250 };
     this.gd_offset = new int[] { 250, 252 };
   }
   
   public TransRzParaBean()
   {
     this.nsrsbh_offset = new int[] { 0, 20 };
     this.gfsbh_offset = new int[] { 20, 40 };
     this.xfsbh_offset = new int[] { 40, 60 };
     this.fp_dm_offset = new int[] { 60, 70 };
     this.fp_hm_offset = new int[] { 70, 78 };
     this.kprq_offset = new int[] { 78, 86 };
     this.kpyear_offset = new int[] { 78, 82 };
     this.kpmonth_offset = new int[] { 82, 84 };
     this.kpday_offset = new int[] { 84, 86 };
     this.je_offset = new int[] { 86, 105 };
     this.se_offset = new int[] { 105, 124 };
     this.mw1_offset = new int[] { 124, 145 };
     this.mw2_offset = new int[] { 145, 166 };
     this.mw3_offset = new int[] { 166, 187 };
     this.mw4_offset = new int[] { 187, 208 };
     this.sym_offset = new int[] { 208, 224 };
     this.jmbb_offset = new int[] { 224, 226 };
     this.gd_offset = new int[] { 226, 228 };
   }
   
   public TransRzParaBean(String p)
   {
     this.newVer = true;
   }
   
   public String getParameter(String pvalue)
   {
     if (this.newVer) {
       return getNewParameter(pvalue);
     }
     String stemp = null;
     
     String str_XmlData = null;
     String str_Mw = null;
     if (pvalue.equals("nsrsbh"))
     {
       stemp = this.strRZData.substring(this.nsrsbh_offset[0], this.nsrsbh_offset[1]).trim();
       return Integer.parseInt(stemp.substring(0, 6)) + stemp.substring(6);
     }
     if (pvalue.equals("QYMC"))
     {
       stemp = this.strRZData.substring(this.nsrsbh_offset[0], this.nsrsbh_offset[1]).trim();
       return Integer.parseInt(stemp.substring(0, 6)) + stemp.substring(6);
     }
     if (pvalue.equals("fpdm")) {
       return this.strRZData.substring(this.fp_dm_offset[0], this.fp_dm_offset[1]);
     }
     if (pvalue.equals("fphm")) {
       return this.strRZData.substring(this.fp_hm_offset[0], this.fp_hm_offset[1]);
     }
     if (pvalue.equals("gsbh"))
     {
       stemp = this.strRZData.substring(this.gfsbh_offset[0], this.gfsbh_offset[1]).trim();
       return Integer.parseInt(stemp.substring(0, 6)) + stemp.substring(6);
     }
     if (pvalue.equals("xsbh"))
     {
       stemp = this.strRZData.substring(this.xfsbh_offset[0], this.xfsbh_offset[1]).trim();
       return Integer.parseInt(stemp.substring(0, 6)) + stemp.substring(6);
     }
     if (pvalue.equals("kprq")) {
       return String.valueOf(Long.valueOf(this.strRZData.substring(this.kprq_offset[0], this.kprq_offset[1])).longValue()).toString();
     }
     if (pvalue.equals("kpyear")) {
       return this.strRZData.substring(this.kpyear_offset[0], this.kpyear_offset[1]);
     }
     if (pvalue.equals("kpmonth")) {
       return this.strRZData.substring(this.kpmonth_offset[0], this.kpmonth_offset[1]);
     }
     if (pvalue.equals("kpday")) {
       return this.strRZData.substring(this.kpday_offset[0], this.kpday_offset[1]);
     }
     if (pvalue.equals("jine"))
     {
       stemp = this.strRZData.substring(this.je_offset[0], this.je_offset[1]).trim();
       int itemp = stemp.indexOf("-");
       if (itemp == -1) {
         itemp = 0;
       }
       return String.valueOf(Double.valueOf(stemp.substring(itemp)).doubleValue()).toString();
     }
     if (pvalue.equals("shuie"))
     {
       stemp = this.strRZData.substring(this.se_offset[0], this.se_offset[1]).trim();
       int itemp = stemp.indexOf("-");
       if (itemp == -1) {
         itemp = 0;
       }
       return String.valueOf(Double.valueOf(stemp.substring(itemp)).doubleValue()).toString();
     }
     if (pvalue.equals("miwen1")) {
       return this.strRZData.substring(this.mw1_offset[0], this.mw1_offset[1]);
     }
     if (pvalue.equals("miwen2")) {
       return this.strRZData.substring(this.mw2_offset[0], this.mw2_offset[1]);
     }
     if (pvalue.equals("miwen3")) {
       return this.strRZData.substring(this.mw3_offset[0], this.mw3_offset[1]);
     }
     if (pvalue.equals("miwen4")) {
       return this.strRZData.substring(this.mw4_offset[0], this.mw4_offset[1]);
     }
     if (pvalue.equals("gdzc"))
     {
       String gd = this.strRZData.substring(this.gd_offset[0], this.gd_offset[1]);
       if (gd.equals("02")) {
         return "0";
       }
       return "1";
     }
     if (pvalue.equals("fpid")) {
       return this.strRZData.substring(this.sym_offset[0], this.sym_offset[1]);
     }
     str_XmlData = null;
     return str_XmlData;
   }
   
   public String getNewParameter(String Para)
   {
     String s = null;String sName = null;String sValue = null;
     try
     {
       StringTokenizer paramTokens = new StringTokenizer(this.strRZData, "&");
       while (paramTokens.hasMoreTokens())
       {
         s = paramTokens.nextToken();
         sName = s.substring(0, s.indexOf("="));
         if (Para.equalsIgnoreCase(sName))
         {
           sValue = s.substring(s.indexOf("=") + 1, s.length());
           if (!Para.equalsIgnoreCase("gdzc")) {
             break;
           }
           if (sValue.equals("02")) {
             return "0";
           }
           return "1";
         }
       }
     }
     catch (Exception e)
     {
       System.out.println("TransRzParaBean.getNewParameter error: " + 
         e.toString());
       
       return null;
     }
     return sValue;
   }
 }